{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/root/mambaforge/envs/dl4/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "found 90 images\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "GPU available: True (cuda), used: True\n",
      "TPU available: False, using: 0 TPU cores\n",
      "IPU available: False, using: 0 IPUs\n",
      "HPU available: False, using: 0 HPUs\n",
      "LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [1]\n",
      "/root/mambaforge/envs/dl4/lib/python3.9/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:441: The 'predict_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=47` in the `DataLoader` to improve performance.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Predicting DataLoader 0: 100%|██████████| 3/3 [00:03<00:00,  0.98it/s]\n",
      "done\n"
     ]
    }
   ],
   "source": [
    "from datasets import CustomDataset, TestDataset\n",
    "from tlhengine.utils import random_split\n",
    "import lightning as L\n",
    "from engine import Model\n",
    "from torch.utils.data.dataloader import DataLoader\n",
    "\n",
    "test_set = TestDataset('data/train')\n",
    "test_loader = DataLoader(test_set, batch_size=32, )\n",
    "model = Model.load_from_checkpoint('/root/code/tianchi/log/noname/version_6/checkpoints/epoch=99-step=900.ckpt')\n",
    "trainer = L.Trainer(max_epochs=100)\n",
    "predictions = trainer.predict(model, dataloaders=test_loader )\n",
    "\n",
    "print('done')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "torch.Size([90, 5])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import torch\n",
    "predictions_cat = torch.cat(predictions, )\n",
    "predictions_cat.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "tensor([[3.9531e-09, 3.4126e-10, 4.5476e-09, 1.6523e-05, 2.0122e-11],\n",
       "        [3.0766e-06, 1.4987e-13, 7.7691e-04, 7.8777e-06, 9.6000e-13],\n",
       "        [5.7531e-08, 2.1138e-06, 1.1213e-08, 1.6730e-06, 7.0126e-10],\n",
       "        [1.8990e-02, 1.0894e-04, 7.8096e-01, 1.5733e-01, 5.7421e-05],\n",
       "        [9.6657e-08, 1.5883e-06, 3.1983e-05, 4.9923e-06, 3.5200e-07],\n",
       "        [5.5889e-05, 9.1993e-04, 2.3543e-06, 1.5473e-04, 9.0390e-07],\n",
       "        [2.6539e-08, 5.2653e-09, 2.1483e-06, 1.6048e-05, 4.1771e-10],\n",
       "        [3.4179e-07, 2.8346e-07, 9.9486e-06, 8.3497e-06, 2.8318e-09],\n",
       "        [1.1905e-03, 1.9827e-06, 9.3638e-04, 3.4300e-01, 5.1372e-04],\n",
       "        [1.9970e-10, 2.5586e-15, 2.9117e-07, 4.7948e-08, 1.0121e-15]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "predictions_cat[:10]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "def convert_to_bit(preds):\n",
    "    bit_values = []\n",
    "    for pred in preds:\n",
    "        this_pred = pred > 0.5\n",
    "        bit_value = 0\n",
    "        for i, v in enumerate(this_pred):\n",
    "            bit_value += v * 2 ** i\n",
    "        bit_values.append(bit_value.item())\n",
    "    return bit_values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "bit_values = convert_to_bit(predictions_cat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0,\n",
       " 0,\n",
       " 0,\n",
       " 4,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 0,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 4,\n",
       " 8,\n",
       " 8,\n",
       " 0,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 8,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 0,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 16,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 0,\n",
       " 0,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 1,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 0,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2,\n",
       " 2]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "bit_values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ele_a90eba393be53616dacd6797a7e6b51a.jpg\n",
      "ele_c2ec1c70166513cd4ea6496ae4df4b09.jpg\n",
      "ele_19df9da574cca5c6ece56490920fd670.jpg\n",
      "ele_e0edacf203e93fe3fee4b8b0f7b44946.jpg\n",
      "ele_e4bb73663e4046287b6af6762f296f5c.jpg\n",
      "ele_4a392df90dc19f50cc8f206e58062150.jpg\n",
      "ele_8cafc2ec861564e44114e2f37f23258f.jpg\n",
      "ele_7f38a7c963004a5cedd2beffb2deabb2.jpg\n",
      "ele_b9aa89ab616eab2c32b43d5662215e85.jpg\n",
      "ele_ccd6fe3c9b2ebc800d0fed6e6623384d.jpg\n",
      "ele_449990ef0bf75934e26fb6e409634b27.jpg\n",
      "ele_951d131b3a5a8b1c5a3a91099ee733b4.jpg\n",
      "ele_309ed13d4933e40b14cd4f162c8f2fd5.jpg\n",
      "ele_9407ad2f166d151589f70234095bfd61.jpg\n",
      "ele_9106f6e6a3ea0fea3d88245a913e0c82.jpg\n",
      "ele_753ff817b2562eb46758a8c6f9d520e6.jpg\n",
      "ele_932c8d8733058e1c56124be797d780b9.jpg\n",
      "ele_6e1e7c6d2c081ed3b67865633d8d8948.jpg\n",
      "ele_f8af02cebfd24d34943b798abd37b7f6.jpg\n",
      "ele_01588f09b32091413b34af8d86aad3ef.jpg\n",
      "ele_149a692b3923d7f06c2c11da175b0dff.jpg\n",
      "ele_86eb8b5e1bdbf858124aa705be9dd96b.jpg\n",
      "ele_fd112d08213fb6426cd925e09c575a75.jpg\n",
      "ele_bddc06149ec0bd665402748d44f4c6ed.jpg\n",
      "ele_6f821785746c70db5da9dd70fe0b575a.jpg\n",
      "ele_ca190f07fdc9a4e6b51f830777f6337c.jpg\n",
      "ele_471ca10692e99891de6e1d14218173d7.jpg\n",
      "ele_a88ea0fb5225afdc57a45a0f3ece6716.jpg\n",
      "ele_28eff6ef2a8b8295046559206dcd23d0.jpg\n",
      "ele_75f0f74b4f43c727b91446222d1847c4.jpg\n",
      "ele_8cd165bb36ecb351352bb572282f982f.jpg\n",
      "ele_b3b971fac7b07114da7f24af8375334a.jpg\n",
      "ele_03727b96d54e774bf78a31aa2b2d89be.jpg\n",
      "ele_ead6637ba5129af1638cccc3ecdc7011.jpg\n",
      "ele_e7d31cf94d47197d9fdd779fcba67928.jpg\n",
      "ele_4098563a04fe9f9b992a270dac769a7c.jpg\n",
      "ele_12cf721a3f85ce390f3662e1d25b0fa9.jpg\n",
      "ele_ceaca6b0b067f07c2a06c60e40a021fc.jpg\n",
      "ele_03f6c8b5a581749169ad2e97fa6fc024.jpg\n",
      "ele_6b74f643e74b9f70689b946d08fedb56.jpg\n",
      "ele_e323956ee7d803eba8f6f6d522689196.jpg\n",
      "ele_08e52e04a415ee12b0b0a15bdfc279bf.jpg\n",
      "ele_555b0a9af8f667496e815a951cbbe292.jpg\n",
      "ele_b4cfb1e89d6acbb8370d934b2928e42b.jpg\n",
      "ele_69bad2f17c2feeca6a61d69307cc3aa9.jpg\n",
      "ele_4c9740acd4e9a772b0d9f8845a498766.jpg\n",
      "ele_b2bc0d7030dba58ae382eb17aa4a9b50.jpg\n",
      "ele_a03da52ea775ad5135b01916e8be30fa.jpg\n",
      "ele_a07df6c53cff764186a95284a9bfd855.jpg\n",
      "ele_5809a45680ef907dd37c3f822184f73f.jpg\n",
      "ele_239139e27d3e95080947fb6dac5779bb.jpg\n",
      "ele_e459151c9ccfe72be95214f2994434a0.jpg\n",
      "ele_d48166ac755b4f93d95f6a5e33cd9e89.jpg\n",
      "ele_d51717063b6de3efa755f37d9c94da61.jpg\n",
      "ele_2c97e45446c990d6ac8dbcbb46b26fcb.jpg\n",
      "ele_562b1dcb419328870bda961afed6b1e5.jpg\n",
      "ele_40c46eb92acd110b4b82809433d94aad.jpg\n",
      "ele_48a1a34d6df97d6ee643d3eee8991df0.jpg\n",
      "ele_abe94d85001596f482f355ed1482c5ae.jpg\n",
      "ele_7458444094fbb89749a6bbda1459b0a4.jpg\n",
      "ele_072eb872fdab29c1d8161223afdeddbb.jpg\n",
      "ele_4e2f28cd0e6d2bb5d98cd3bcb307e054.jpg\n",
      "ele_f0e90018b851453650a8aa6077d82741.jpg\n",
      "ele_41923f3f25b29e0e89fe2e6b044c66e8.jpg\n",
      "ele_457db0fbbbf5f8ec667a169bdb30ba29.jpg\n",
      "ele_370ff57bc0350db8651ae9d0f18b1ad9.jpg\n",
      "ele_7031298d9e133f271d0e29fe11119560.jpg\n",
      "ele_9f6870881d36175f413d55e6d11e2fdb.jpg\n",
      "ele_32d9ba28af48f12c94a5bf5a681e6306.jpg\n",
      "ele_166e34b095d5f43b209ee7e81a8d0488.jpg\n",
      "ele_a0c1164d79e6e0f8eda68c1b3fa4e740.jpg\n",
      "ele_2029a2dcbac1ce8689c19566bda89eff.jpg\n",
      "ele_df43bd3a971a4d1265e758ac71d7a5a6.jpg\n",
      "ele_05317ffbc47a9210a35e6db486e69203.jpg\n",
      "ele_9deb5fb2e9de1be6ac6d74e6e3f575d4.jpg\n",
      "ele_57c85bd7a1e5c9fdaff43667e040b4c2.jpg\n",
      "ele_2470702b14127e77cec02a13d873195c.jpg\n",
      "ele_d06204877dd3c15b71b77cabb7fe3128.jpg\n",
      "ele_553d9db14da9dc84423fabc36ecb412c.jpg\n",
      "ele_ae384382627d468abe886d55d21b824e.jpg\n",
      "ele_d578208b976ed3feb49aa5e0b0c92aa4.jpg\n",
      "ele_92f2766c139e4136d197fbaeb0033c56.jpg\n",
      "ele_080f32d571940a134cc2e5721068dbf4.jpg\n",
      "ele_63e20c854a4f4527eb7c3c08561bc956.jpg\n",
      "ele_5dff4c66e07629d0fd7ac7f8ebe02c9c.jpg\n",
      "ele_5570dc8768a3000eedc2229982ec9c2d.jpg\n",
      "ele_7c00e495287abca4da5682520d9c5116.jpg\n",
      "ele_daf4db6f67a264a4000c001c0fd392da.jpg\n",
      "ele_d81d0a7012d7623dca81ce65e938cae2.jpg\n",
      "ele_836dd936af2ec2cfbcec84a43e559b82.jpg\n"
     ]
    }
   ],
   "source": [
    "import os\n",
    "filenames = []\n",
    "for path in test_set.imgs:\n",
    "    print(os.path.basename(path))\n",
    "    filenames.append(os.path.basename(path))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['ele_a90eba393be53616dacd6797a7e6b51a.jpg',\n",
       " 'ele_c2ec1c70166513cd4ea6496ae4df4b09.jpg',\n",
       " 'ele_19df9da574cca5c6ece56490920fd670.jpg',\n",
       " 'ele_e0edacf203e93fe3fee4b8b0f7b44946.jpg',\n",
       " 'ele_e4bb73663e4046287b6af6762f296f5c.jpg',\n",
       " 'ele_4a392df90dc19f50cc8f206e58062150.jpg',\n",
       " 'ele_8cafc2ec861564e44114e2f37f23258f.jpg',\n",
       " 'ele_7f38a7c963004a5cedd2beffb2deabb2.jpg',\n",
       " 'ele_b9aa89ab616eab2c32b43d5662215e85.jpg',\n",
       " 'ele_ccd6fe3c9b2ebc800d0fed6e6623384d.jpg',\n",
       " 'ele_449990ef0bf75934e26fb6e409634b27.jpg',\n",
       " 'ele_951d131b3a5a8b1c5a3a91099ee733b4.jpg',\n",
       " 'ele_309ed13d4933e40b14cd4f162c8f2fd5.jpg',\n",
       " 'ele_9407ad2f166d151589f70234095bfd61.jpg',\n",
       " 'ele_9106f6e6a3ea0fea3d88245a913e0c82.jpg',\n",
       " 'ele_753ff817b2562eb46758a8c6f9d520e6.jpg',\n",
       " 'ele_932c8d8733058e1c56124be797d780b9.jpg',\n",
       " 'ele_6e1e7c6d2c081ed3b67865633d8d8948.jpg',\n",
       " 'ele_f8af02cebfd24d34943b798abd37b7f6.jpg',\n",
       " 'ele_01588f09b32091413b34af8d86aad3ef.jpg',\n",
       " 'ele_149a692b3923d7f06c2c11da175b0dff.jpg',\n",
       " 'ele_86eb8b5e1bdbf858124aa705be9dd96b.jpg',\n",
       " 'ele_fd112d08213fb6426cd925e09c575a75.jpg',\n",
       " 'ele_bddc06149ec0bd665402748d44f4c6ed.jpg',\n",
       " 'ele_6f821785746c70db5da9dd70fe0b575a.jpg',\n",
       " 'ele_ca190f07fdc9a4e6b51f830777f6337c.jpg',\n",
       " 'ele_471ca10692e99891de6e1d14218173d7.jpg',\n",
       " 'ele_a88ea0fb5225afdc57a45a0f3ece6716.jpg',\n",
       " 'ele_28eff6ef2a8b8295046559206dcd23d0.jpg',\n",
       " 'ele_75f0f74b4f43c727b91446222d1847c4.jpg',\n",
       " 'ele_8cd165bb36ecb351352bb572282f982f.jpg',\n",
       " 'ele_b3b971fac7b07114da7f24af8375334a.jpg',\n",
       " 'ele_03727b96d54e774bf78a31aa2b2d89be.jpg',\n",
       " 'ele_ead6637ba5129af1638cccc3ecdc7011.jpg',\n",
       " 'ele_e7d31cf94d47197d9fdd779fcba67928.jpg',\n",
       " 'ele_4098563a04fe9f9b992a270dac769a7c.jpg',\n",
       " 'ele_12cf721a3f85ce390f3662e1d25b0fa9.jpg',\n",
       " 'ele_ceaca6b0b067f07c2a06c60e40a021fc.jpg',\n",
       " 'ele_03f6c8b5a581749169ad2e97fa6fc024.jpg',\n",
       " 'ele_6b74f643e74b9f70689b946d08fedb56.jpg',\n",
       " 'ele_e323956ee7d803eba8f6f6d522689196.jpg',\n",
       " 'ele_08e52e04a415ee12b0b0a15bdfc279bf.jpg',\n",
       " 'ele_555b0a9af8f667496e815a951cbbe292.jpg',\n",
       " 'ele_b4cfb1e89d6acbb8370d934b2928e42b.jpg',\n",
       " 'ele_69bad2f17c2feeca6a61d69307cc3aa9.jpg',\n",
       " 'ele_4c9740acd4e9a772b0d9f8845a498766.jpg',\n",
       " 'ele_b2bc0d7030dba58ae382eb17aa4a9b50.jpg',\n",
       " 'ele_a03da52ea775ad5135b01916e8be30fa.jpg',\n",
       " 'ele_a07df6c53cff764186a95284a9bfd855.jpg',\n",
       " 'ele_5809a45680ef907dd37c3f822184f73f.jpg',\n",
       " 'ele_239139e27d3e95080947fb6dac5779bb.jpg',\n",
       " 'ele_e459151c9ccfe72be95214f2994434a0.jpg',\n",
       " 'ele_d48166ac755b4f93d95f6a5e33cd9e89.jpg',\n",
       " 'ele_d51717063b6de3efa755f37d9c94da61.jpg',\n",
       " 'ele_2c97e45446c990d6ac8dbcbb46b26fcb.jpg',\n",
       " 'ele_562b1dcb419328870bda961afed6b1e5.jpg',\n",
       " 'ele_40c46eb92acd110b4b82809433d94aad.jpg',\n",
       " 'ele_48a1a34d6df97d6ee643d3eee8991df0.jpg',\n",
       " 'ele_abe94d85001596f482f355ed1482c5ae.jpg',\n",
       " 'ele_7458444094fbb89749a6bbda1459b0a4.jpg',\n",
       " 'ele_072eb872fdab29c1d8161223afdeddbb.jpg',\n",
       " 'ele_4e2f28cd0e6d2bb5d98cd3bcb307e054.jpg',\n",
       " 'ele_f0e90018b851453650a8aa6077d82741.jpg',\n",
       " 'ele_41923f3f25b29e0e89fe2e6b044c66e8.jpg',\n",
       " 'ele_457db0fbbbf5f8ec667a169bdb30ba29.jpg',\n",
       " 'ele_370ff57bc0350db8651ae9d0f18b1ad9.jpg',\n",
       " 'ele_7031298d9e133f271d0e29fe11119560.jpg',\n",
       " 'ele_9f6870881d36175f413d55e6d11e2fdb.jpg',\n",
       " 'ele_32d9ba28af48f12c94a5bf5a681e6306.jpg',\n",
       " 'ele_166e34b095d5f43b209ee7e81a8d0488.jpg',\n",
       " 'ele_a0c1164d79e6e0f8eda68c1b3fa4e740.jpg',\n",
       " 'ele_2029a2dcbac1ce8689c19566bda89eff.jpg',\n",
       " 'ele_df43bd3a971a4d1265e758ac71d7a5a6.jpg',\n",
       " 'ele_05317ffbc47a9210a35e6db486e69203.jpg',\n",
       " 'ele_9deb5fb2e9de1be6ac6d74e6e3f575d4.jpg',\n",
       " 'ele_57c85bd7a1e5c9fdaff43667e040b4c2.jpg',\n",
       " 'ele_2470702b14127e77cec02a13d873195c.jpg',\n",
       " 'ele_d06204877dd3c15b71b77cabb7fe3128.jpg',\n",
       " 'ele_553d9db14da9dc84423fabc36ecb412c.jpg',\n",
       " 'ele_ae384382627d468abe886d55d21b824e.jpg',\n",
       " 'ele_d578208b976ed3feb49aa5e0b0c92aa4.jpg',\n",
       " 'ele_92f2766c139e4136d197fbaeb0033c56.jpg',\n",
       " 'ele_080f32d571940a134cc2e5721068dbf4.jpg',\n",
       " 'ele_63e20c854a4f4527eb7c3c08561bc956.jpg',\n",
       " 'ele_5dff4c66e07629d0fd7ac7f8ebe02c9c.jpg',\n",
       " 'ele_5570dc8768a3000eedc2229982ec9c2d.jpg',\n",
       " 'ele_7c00e495287abca4da5682520d9c5116.jpg',\n",
       " 'ele_daf4db6f67a264a4000c001c0fd392da.jpg',\n",
       " 'ele_d81d0a7012d7623dca81ce65e938cae2.jpg',\n",
       " 'ele_836dd936af2ec2cfbcec84a43e559b82.jpg']"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "filenames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>filename</th>\n",
       "      <th>result</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>ele_a90eba393be53616dacd6797a7e6b51a.jpg</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ele_c2ec1c70166513cd4ea6496ae4df4b09.jpg</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ele_19df9da574cca5c6ece56490920fd670.jpg</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>ele_e0edacf203e93fe3fee4b8b0f7b44946.jpg</td>\n",
       "      <td>4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>ele_e4bb73663e4046287b6af6762f296f5c.jpg</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>85</th>\n",
       "      <td>ele_5570dc8768a3000eedc2229982ec9c2d.jpg</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>86</th>\n",
       "      <td>ele_7c00e495287abca4da5682520d9c5116.jpg</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>ele_daf4db6f67a264a4000c001c0fd392da.jpg</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>ele_d81d0a7012d7623dca81ce65e938cae2.jpg</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>ele_836dd936af2ec2cfbcec84a43e559b82.jpg</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>90 rows × 2 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                    filename  result\n",
       "0   ele_a90eba393be53616dacd6797a7e6b51a.jpg       0\n",
       "1   ele_c2ec1c70166513cd4ea6496ae4df4b09.jpg       0\n",
       "2   ele_19df9da574cca5c6ece56490920fd670.jpg       0\n",
       "3   ele_e0edacf203e93fe3fee4b8b0f7b44946.jpg       4\n",
       "4   ele_e4bb73663e4046287b6af6762f296f5c.jpg       0\n",
       "..                                       ...     ...\n",
       "85  ele_5570dc8768a3000eedc2229982ec9c2d.jpg       2\n",
       "86  ele_7c00e495287abca4da5682520d9c5116.jpg       2\n",
       "87  ele_daf4db6f67a264a4000c001c0fd392da.jpg       2\n",
       "88  ele_d81d0a7012d7623dca81ce65e938cae2.jpg       2\n",
       "89  ele_836dd936af2ec2cfbcec84a43e559b82.jpg       2\n",
       "\n",
       "[90 rows x 2 columns]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "df = pd.DataFrame(dict(filename=filenames, result=bit_values))\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('train.csv', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_set = TestDataset('data/train')\n",
    "test_loader = DataLoader(test_set, batch_size=32, )\n",
    "model = Model.load_from_checkpoint('/root/code/tianchi/log/noname/version_6/checkpoints/epoch=99-step=900.ckpt')\n",
    "trainer = L.Trainer(max_epochs=100)\n",
    "predictions = trainer.predict(model, dataloaders=test_loader )"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dl4",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
